package com.hualan.zhsq.controller.car;

import com.hualan.zhsq.entity.car.MonthlyCard;
import com.hualan.zhsq.service.car.MonthlyCardService;
import com.hualan.zhsq.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @ClassName MonthlyCardController
 * @Description TODO
 * @Author ZheRan
 * @Date 2025年08月07日 下午4:12
 * @Version 1.0
 */
@RestController
public class MonthlyCardController {
    @Qualifier("monthlyCardService")
    @Autowired
    private MonthlyCardService monthlyCardService;

    //插入一条数据
    @PostMapping("/monthlyCard/add")
    public Result add(@RequestBody MonthlyCard monthlyCard){
        return Result.success(monthlyCardService.add(monthlyCard));
    }

    //逻辑删除一条数据
    @DeleteMapping("/monthlyCard/remove/{id}")
    public Result remove(@PathVariable Integer id){
        return Result.success(monthlyCardService.remove(id));
    }

    //批量逻辑删除数据
    @DeleteMapping("/monthlyCard/removeBatch")
    public Result removeBatch(Integer[] ids){
        return Result.success(monthlyCardService.removeBatch(ids));
    }

    //修改一条数据
    @PutMapping("/monthlyCard/edit")
    public Result edit(@RequestBody MonthlyCard monthlyCard){
        return  Result.success(monthlyCardService.edit(monthlyCard));
    }

    //根据id查询数据
    @GetMapping("/monthlyCard/findById/{id}")
    public Result findById(@PathVariable Integer id){
        return Result.success(monthlyCardService.findById(id));
    }

    //查询所有数据
    @GetMapping("/monthlyCard/findPage")
    public Result findPage(){
        return Result.success(monthlyCardService.findPage(1,10,new MonthlyCard()));
    }

    //根据条件查询数据
    @GetMapping("git")
    public Result<Map<String,Object>> monthlyCardResident(Integer pageNum, Integer pageSize, MonthlyCard monthlyCard){
        return Result.success(monthlyCardService.monthlyCardResident(pageNum,pageSize,monthlyCard));
    }

}
